
package com.amado.springboot.springbootmybatish2.controll;

import com.amado.springboot.springbootmybatish2.domain.User;
import com.amado.springboot.springbootmybatish2.domain.UserMoney;
import com.amado.springboot.springbootmybatish2.service.UserService;
import com.amado.springboot.springbootmybatish2.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author wangyl-910
 * @description
 * @date 2017/11/25
 * @see
 */
@Controller
@RequestMapping("/user")
public class UserControll {

    @Autowired
    private UserService userService;

    @ResponseBody
    @GetMapping("/{id}")
    public User getUser(@PathVariable("id") Long id) {
        System.out.println(id);
        return userService.getUser(id);
    }

    @ResponseBody
    @GetMapping("/add")
    public User addUser() {
        UserVO user = new UserVO();
        user.setName("name");
        user.setAddress("address");
        UserMoney money = new UserMoney();
        money.setMoney(11);
        user.setUserMoney(money);
        return userService.addUser(user);
    }
}
